﻿Imports CustomTshirtFinal

Public Class Usuarios

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim form As New UsuarioNuevo
        form.MdiParent = Me.MdiParent
        form.Usuarios = Me
        form.Show()
    End Sub

    Private Sub Usuarios_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With Me.dgvUsuarios.ColumnHeadersDefaultCellStyle
            .BackColor = Color.Green
            .ForeColor = Color.DarkGreen

        End With
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim criterio As String = Me.txtBuscar.Text

        Dim negocio As New UsuarioNegocio
        Dim pedido As Collection = negocio.buscarPorNombre(criterio)
        Me.dgvUsuarios.DataSource = pedido
        Me.dgvUsuarios.EditMode = False

        Me.dgvUsuarios.Columns(0).HeaderText = "Id Usuario"
        Me.dgvUsuarios.Columns(1).HeaderText = "Nombre"
        Me.dgvUsuarios.Columns(2).HeaderText = "Apellido"
        Me.dgvUsuarios.Columns(3).HeaderText = "Teléfono"
        Me.dgvUsuarios.Columns(4).HeaderText = "Correo"
        Me.dgvUsuarios.Columns(5).HeaderText = "Sexo"
        Me.dgvUsuarios.Columns(4).HeaderText = "Contraseña"
    End Sub

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim selecionado = Me.dgvUsuarios.CurrentRow.Cells(0).Value.ToString

        Dim form As New UsuarioNuevo
        form.MdiParent = Me.MdiParent
        form.lblId.Text = selecionado
        form.Usuarios = Me
        form.Show()
    End Sub

    Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        Dim seleccionado = Me.dgvUsuarios.CurrentRow.Cells(0).Value.ToString
        Dim negocio As New UsuarioNegocio
        negocio.eliminar(seleccionado)
        dgvUsuarios.DataSource = ""
    End Sub
End Class